package com.baidu.infinity.ui.view

import android.content.Context
import android.util.AttributeSet
import android.util.TypedValue
import android.view.Gravity
import android.view.ViewGroup
import com.baidu.infinity.R
import com.baidu.infinity.model.IconModel
import io.github.florent37.shapeofview.shapes.CircleView

class CircleIconTextView(
    context: Context,
    attrs: AttributeSet ?= null
): CircleView(context,attrs) {
    private val iconTextView: IconTextView
    init {
        iconTextView = IconTextView(context)
        val lp = LayoutParams(LayoutParams.MATCH_PARENT,LayoutParams.MATCH_PARENT)
        addView(iconTextView,lp)
        val osa = context.obtainStyledAttributes(attrs,R.styleable.CircleIconTextView)
        val iconTextSize = osa.getDimension(R.styleable.CircleIconTextView_icon_text_size_sp,20f)
        osa.recycle()
        iconTextView.setTextSize(TypedValue.COMPLEX_UNIT_SP,iconTextSize)

    }
    fun setIconModel(model: IconModel){
        iconTextView.setIconModel(model)
    }
    fun cancelSelectedColor(){
        iconTextView.cancelSelectedColor()
    }
    fun setOnCustomClick(onClick: ()->Unit){
        iconTextView.onClick = onClick
    }

}